<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
        <script type="text/javascript">
            var estado = false;
            var count = 0;
            function cuenta() {
                for (var i = 0; i < 999999999; i++) {
                }
                estado = true;
            }

            function cambio() {
                estado = false;
                count++;
                document.getElementById("writeContent").innerHTML = "cambio " + count;
            }

            var inc = 0;
            function increase() {
                setTimeout(function () {
                    console.log(inc++);
                    increase();
                }, 500);
            }
            increase();

            var FunctionOne = function () {
                // create a deferred object
                var r = $.Deferred();

                // do whatever you want (e.g. ajax/animations other asyc tasks)

                setTimeout(function () {
                    // and call `resolve` on the deferred object, once you're done
                    r.resolve();
                }, 2500);

                // return the deferred object
                return r;
            };

            // define FunctionTwo as needed
            var FunctionTwo = function () {
                console.log('FunctionTwo');
            };

            // call FunctionOne and use the `done` method
            // with `FunctionTwo` as it's parameter
            FunctionOne().done(FunctionTwo);

            $(document).ready(function () {
                $(".btn_test").click(function () {
                    console.log("una prueba");
                });
            });
        </script>
    </head>
    <body>
        <div id="writeContent">TODO write content</div>
        <input type="button" onclick="javascript: cuenta();
                for (; !estado; ) {
                }
                cambio();" value="Click">
        <input value="click2" type="button" onclick="FunctionOne().done(FunctionTwo);">
        <div id="div_test" style="height: 50px; width: 100px; background-color: bisque">
            <input type="button" value="btn_test" class="btn_test">
        </div>
    </body>
</html>
